/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.DragonPokerServer.Rules;

import java.util.ArrayList;
import org.DragonPokerServer.Classes.Card;
import org.DragonPokerServer.Classes.HandPlayer;
import org.DragonPokerServer.Classes.Points;
import org.DragonPokerServer.Thread.ThreadUser;

/**
 *
 * @author nykola
 */
public class FlushRule extends GenericRule{

    @Override
    public int processRequest(ArrayList<Card> cards, HandPlayer hp) {
                System.out.println("Rules: FlushRule");
                hp.setPoints(5);
                return 0;
    }


    @Override
    public boolean isToProcessing(ArrayList<Card> cards, HandPlayer hp) {
        if (checkCards(cards, hp.getCards()) == true) {
            return true;
        }
        else
            setNext(new StraightRule());
        return false;
    }

    public boolean checkCards(ArrayList<Card> tablecards, ArrayList<Card> playercards){
        ArrayList<Card> cards = new ArrayList<Card>();
        cards.add(playercards.get(0));
        cards.add(playercards.get(1));
        for (Card a : tablecards) {
            cards.add(a);
        }
        int[] suit = new int[4];
        for(int i = 0; i < cards.size(); i++){
                suit[cards.get(i).getSuit() - 1]++;
        }

        for(int i = 0; i < suit.length; i++){
            if(suit[i] >= 5)
                return true;
        }


        return false;

    }

   @Override
   public ArrayList getWinners(ArrayList<Card> communityCards, ArrayList<HandPlayer> playerCards) {
      throw new UnsupportedOperationException("Not supported yet.");
   }



}
